﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace Infinity.Expressions.Core
{
	public class FunctionCollection : Dictionary<string, List<MethodInfo>>
	{
		public FunctionCollection Add(MethodInfo method)
		{
			return Add(method.Name, method);
		}

		public FunctionCollection Add(string functionName, MethodInfo method)
		{
			List<MethodInfo> list;
			if (this.TryGetValue(functionName, out list) && list != null)
			{
				list.Add(method);
			}
			else
			{
				list = new List<MethodInfo>() { method };
				this.Add(functionName, list);
			}
			return this;
		}
	}
}
